package com.yjc.controller;

import com.yjc.api.Computer;
import com.yjc.entity.Result;
import com.yjc.spring.boot.context.DynamicLoadSpringContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author 闫佳成
 * @version: 1.0
 * @since 2024/10/9 18:16
 */
@RequestMapping("/class")
@RestController
public class ClassController {

    @GetMapping("compute")
    public Result compute(double a, double b) {
        ConfigurableListableBeanFactory beanFactory = DynamicLoadSpringContext.getInstance().getContext();
        Computer computer = beanFactory.getBean(Computer.class);
        double compute = computer.compute(a, b);
        return new Result(compute);
    }
}
